package com.example.demo.model.enums;

/**
 * 用户状态枚举
 */
public enum UserStatus {
        DISABLED(0, "禁用"),
        ENABLED(1, "正常");

        private final int code;
        private final String description;

    UserStatus(int code, String description) {
        this.code = code;
        this.description = description;
    }

    public int getCode() {
        return code;
    }

    public String getDescription() {
        return description;
    }

    // 根据代码值返回对应的枚举实例
    public static UserStatus of(int code) {
        for (UserStatus status : UserStatus.values()) {
            if (status.getCode() == code) {
                return status;
            }
        }
        throw new IllegalArgumentException("Invalid UserStatus code: " + code);
    }
}